Skip to content

Conversation

@vchamarthi
Copy link

@vchamarthi vchamarthi commented Feb 5, 2026

This PR introduce the plugin feature to capture and format pytest warnings to process it in internal CI.
These changes will not add any overhead to existing pytest scope. This feature can be fully enabled/disabled by env var - DPNP_INFRA_WARNINGS_ENABLE

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

Comment on lines 80 to 88
os.makedirs(self.directory, exist_ok=True)
self._events_file = os.path.join(self.directory, self.events_artifact)
self._events_fp = open(
self._events_file,
"w",
encoding="utf-8",
buffering=1,
newline="\n",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be safe and clear to use from pathlib import Path and then:

Suggested change
os.makedirs(self.directory, exist_ok=True)
self._events_file = os.path.join(self.directory, self.events_artifact)
self._events_fp = open(
self._events_file,
"w",
encoding="utf-8",
buffering=1,
newline="\n",
)
p = Path(self.directory).expanduser().resolve()
if p.exists() and not p.is_dir():
raise ValueError(f"{p} exists and is not a directory")
p.mkdir(parents=True, exist_ok=True)
if Path(self.self.events_artifact).name != self.events_artifact:
raise ValueError(f"Invalid filename (must not contain path parts): {self._events_file}")
self._events_file = p / self.events_artifact
self._events_fp = self._events_file.open(mode="w", encoding="utf-8", buffering=1, newline="\n")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion that works safe across platforms. I have adopted you suggestion.
Since this is a public recipe, my agenda here is to not raise error and break the workflow because of this plugin for what ever the reason. This would rather print and artifact wont be created.

@vchamarthi vchamarthi force-pushed the dpnp-warnings-plugin branch from a337f4d to b209cab Compare February 9, 2026 21:33
except Exception as exc:
self._events_fp = None
self._events_file = None
self.directory = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It holds the env variable and it was set during the init. Why do we want to reset that here?

EVENT_PREFIX = "DPNP_WARNING_EVENT - "

def __init__(self):
self.enabled = bool(warn_config.infra_warnings_enable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to cast, already holds a boolean value:

Suggested change
self.enabled = bool(warn_config.infra_warnings_enable)
self.enabled = warn_config.infra_warnings_enable

Comment on lines +217 to +219
except Exception:
pass
self._events_fp = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we don't have any special exception handling:

Suggested change
except Exception:
pass
self._events_fp = None
finally:
self._events_fp = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants